import React from 'react';
import ReactDom from 'react-dom';
import App from './containers/App'
import Provider from './redux/provider'
import {applyMiddleware, createStore} from "./redux/redux";
import reducer from './redux/reducers'
let store =createStore(reducer)

let logger=store=>next=>action=>{
    console.log('之前'+JSON.stringify(store.getState()))
    console.log(action)
    next(action)
    console.log('之后'+JSON.stringify(store.getState()))
}
/*var logger = function logger(store) {
    return function (next) {
        return function (action) {
            console.log('之前' + JSON.stringify(store.getState()));
            console.log(action);
            next(action);
            console.log('之后' + JSON.stringify(store.getState()));
        };
    };
};*/
/*
//异步操作
let thunk=store=>next=>action=>{
    console.log(action)
    console.log(typeof action==='function')
    if(typeof action==='function')
        return action(next)
    return next(action)
}
//
let store=applyMiddleware(logger)(createStore)(reducer);
*/

ReactDom.render(
    <Provider store={store}>
        <App/>
    </Provider>,
    document.getElementById('app')
);
